package com.shangqing.system.service.impl;

import com.shangqing.system.domain.caoyuan.vo.CityVo;
import com.shangqing.system.mapper.CityMapper;
import org.springframework.beans.factory.annotation.Autowired;

public class CityImpl {
    @Autowired
    public CityMapper cityMapper;

    public  CityVo cityVos(CityVo list) {
        if (list.getParentId() == 0) {
            return null;      //递归出口
        } else {

            CityVo vo = cityMapper.select(list.getParentId());//获取父ID对应的地址
            CityVo cityVo = new CityVo();//封装
            cityVo.setId(vo.getId());
            cityVo.setCityName(vo.getCityName());
            cityVo.setParentId(vo.getParentId());
            cityVo.setCities(cityVos(vo)); //进行递归进口
            return cityVo;
        }
    }

}
